Imports System.Xml.Serialization

Public Class RuntimeMappings
    Inherits XEntityModelElementBase

    ''' <summary>Initializes an instance of the <see cref="RuntimeMappings" /> class.
    ''' This is the default constructor for this class.</summary>
    Public Sub New()
        MyBase.New("Mappings", EdmxXmlNamespace)
    End Sub

    ''' <summary>Initializes an instance of the <see cref="RuntimeMappings" /> class.</summary>
    ''' <param name="other">An <see cref="System.Xml.Linq.XElement"/> object to copy from.</param>
    Public Sub New(ByVal other As XElement)
        MyBase.New(other)
    End Sub

    <AutoLoad()> _
    <XmlElement([Namespace]:=CSXmlNamespace)> _
    Public Property Mapping() As Mapping.Mapping
        Get
            Return DirectCast(Me.Element(XName.Get("Mapping", CSXmlNamespace)), EdmxEditor.Mapping.Mapping)
        End Get
        Set(ByVal value As Mapping.Mapping)
            If (DirectCast(value, XElement).Name <> XName.Get("Mapping", CSXmlNamespace)) Then
                Throw New ArgumentException("Invalid Element")
            End If
            If (Me.Mapping IsNot Nothing) Then
                Me.Mapping.Remove()
            End If
            Me.Add(New EdmxEditor.Mapping.Mapping(value))
        End Set
    End Property

End Class
